package com.xiaoxin.nmzp.server.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.xiaoxin.nmzp.server.entity.domain.NmzpCollect;
import com.xiaoxin.nmzp.server.entity.domain.NmzpJob;
import com.xiaoxin.nmzp.server.service.NmzpCollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nmzp/collect")
public class CollectController {
    @Autowired
    private NmzpCollectService nmzpCollectService;
    /**
     * 查询当前用户收藏
     */
    @GetMapping("/list")
    public AjaxResult list() {
        List<NmzpJob> nmzpCollects = nmzpCollectService.getUserCollect();
        return AjaxResult.success(nmzpCollects);
    }

    /**
     * 添加收藏
     */
    @GetMapping("/add/{id}")
    public AjaxResult add(@PathVariable("id") Long jobId) {
        nmzpCollectService.addCollect(jobId);
        return AjaxResult.success();
    }

    /**
     * 删除收藏
     * @param id
     * @return
     */
    @DeleteMapping("/del/{id}")
    public AjaxResult delete(@PathVariable("id") Long id) {
        nmzpCollectService.removeById(id);
        return AjaxResult.success();
    }

}
